Smtp.NET

Index Smtp.NET version 3.0.1327.25114

Welcome!

  • Thank you for using Smtp.NET version 3 by ExclamationSoft! We have worked hard provide to you with the easiest to use email component for the .NET Framework.

  • For a complete list of up-to-date information on Smtp.NET please visit the Smtp.NET website: http://www.SmtpDotNet.com, browse the documentation, or try the examples.

Installation and Usage

  • To view installation instructions, click here:

    Follow these steps to install and reference Smtp.NET in your VS.NET project:

    1. Add a reference to the Smtp.NET assembly "SmtpDotNet.dll": In the solution explorer of your project, right click on "References".
    2. Select "Add Reference"
      To view animated, instructions, click here:
    3. A list of the assemblies installed in the GAC (Global Assembly Cache) is displayed.
    4. Scroll down the list and select SmtpDotNet.
    5. Click the "Select" button.
      To view animated, instructions, click here:
    6. Click the "OK" button.
    7. The assembly should now be added to your list of references.

  • To view usage instructions, click here:

    Follow these steps to use Smtp.NET in your VS.NET project:

    1. Open your page with code (either the .cs or .vb file) and add a using statement:
      using SmtpDotNet;
    2. In your code where you would like to send an email message, create an instance of the Smtp.NET object:
      SmtpServer mySmtpServer = new SmtpServer();
    3. Set the properties for the "from" and "to" email addresses:
      mySmtpServer.FromAddress = "from@domain.com";
      mySmtpServer.ToAddress = "to@domain.com";
    4. Send the mail message:
      mySmtpServer.Send();
    5. Complile the project to ensure you don't have any errors.
    To view animated, instructions, click here:

Examples

The complete examples are ready for immediate use:

  • Smtp.NETDemoApp is a Windows Application Solution. It is located under the installation directory in the "Smtp.NETDemoApp" folder. This application demonstrates email functionality that Smtp.NET can provide for your application.
  • Smtp.NETDemoWeb - Web Application Solution. This web application project is located under the "\Program Files\ExclamationSoft\Smtp.NET 3 [TRIAL]\Smtp.NETDemoWeb" folder. It demonstrates email functionality that Smtp.NET can provide for your web application. Each working example provides basic instruction and code samples you can cut-and-paste into your project.
    Click Here to go to the Examples (Requires the Examples to be installed)

    More information...
    • NOTE: The setup program should have automatically created a virtual directory and initialized the web application for you. If there was a problem creating the virtual directory, please follow these instructions:
      • Option 1: Create a Virtual directory to the above mentioned Smtp.NETDemoWeb directory through the IIS Management Console. Name the virtual directory "Smtp.NETWeb"
      • Option 2: Move this folder under the \Inetpub\wwwroot directory, then through the IIS Management Console, create a web application for the folder "Smtp.NETDemoWeb" name the virtual directory "Smtp.NETWeb". Once it is created, you should be able to access it here: http://localhost/Smtp.NETWeb/default.aspx

Support and Information

  • ExclamationSoft fully supports Smtp.NET. You can receive email support for the duration of your 30-day trial period through our online support system: http://www.exHelp.com

  • When you purchase Smtp.NET, you will have the option to purchase our Annual Support Agreement. Please see our website for more details.

Links

Examples Home
Go to the examples index. (Requires
Examples to be installed)

Smtp.NET Website
Visit the Smtp.NET website for updated information on this product.
© Copyright 2000-2003 ExclamationSoft Corporation


SmtpDotNet

Smtp.NET 3 Documentation

SmtpDotNet Namespace

The main namespace for all of Smtp.NET functionality. This namespace must be included in your code in order to utilize the main class SmtpServer.

Namespace hierarchy

Classes

Class | Description
CoreServer | Summary description for CoreServer.
SmtpServer | The main class for SmtpDotNet.

Enumerations

Enumeration | Description
AddressTypes | The three address types, TO, CC, BCC.
BodyFormatTypes | The two message body format types: PLAIN, HTML
CharsetTypes | The two different supported character sets for message body and alternate body.
ContentTypes | Supported MIME part content types
EncodingTypes | Supported MIME Encoding types
MessagePriorityTypes | The three message priority types
ReturnCodes | Return codes from the object

Copyright 2002-2003 ExclamationSoft Corporation


AddressTypes Enumeration

The three address types, TO, CC, BCC.

[Visual Basic]
Public Enum AddressTypes
[C#]
public enum AddressTypes

Remarks

TO = to reicipient

Members

Member Name | Description
TO | To recipient
CC | Carbon Copy recipient
BCC | Blind Carbon Copy recipient

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpDotNet Namespace

Copyright 2002-2003 ExclamationSoft Corporation

Generated from assembly SmtpDotNet [3.0.1326.34340]


BodyFormatTypes Enumeration

The two message body format types: PLAIN, HTML

[Visual Basic]
Public Enum BodyFormatTypes
[C#]
public enum BodyFormatTypes

Members

Member Name | Description
PLAIN | Plain text with no formatting
HTML | Text and HTML formatting

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpDotNet Namespace


CharsetTypes Enumeration

The two different supported character sets for message body and alternate body.

[Visual Basic]
Public Enum CharsetTypes
[C#]
public enum CharsetTypes

Members

Member Name | Description
US_ASCII | The standard US Ascii standard character set.
ISO_8859_1 | High character set

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpDotNet Namespace


ContentTypes Enumeration

Supported MIME part content types

[Visual Basic]
Public Enum ContentTypes
[C#]
public enum ContentTypes

Members

Member Name | Description
TEXT_PLAIN | Plain text
TEXT_HTML | Html formatted text
IMAGE_GIF | .gif image
IMAGE_JPG | .jpg image
APPLICATION_OCTETSTREAM | application/octet stream - usually an attachment
IMAGE_PNG | .png image

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpDotNet Namespace


CoreServer Class

Summary description for CoreServer.

For a list of all members of this type, see CoreServer Members.

System.Object
CoreServer

[Visual Basic]
MustInherit Public Class CoreServer
[C#]
public abstract class CoreServer

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

CoreServer Members | SmtpDotNet Namespace


CoreServer Members

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
SaveInMemoryLog | Saves an in-memory log to a physical file as specified by LogFilename
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

CoreServer Class | SmtpDotNet Namespace


CoreServer Methods

The methods of the CoreServer class are listed below. For a complete list of CoreServer class members, see the CoreServer Members topic.

Public Instance Methods

Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
SaveInMemoryLog | Saves an in-memory log to a physical file as specified by LogFilename
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

CoreServer Class | SmtpDotNet Namespace


CoreServer.SaveInMemoryLog Method

Saves an in-memory log to a physical file as specified by LogFilename

[Visual Basic]
Overridable Public Function SaveInMemoryLog() As Boolean
[C#]
public virtual bool SaveInMemoryLog();

Return Value

true if successful, false if failed

See Also

CoreServer Class | CoreServer Members | SmtpDotNet Namespace


EncodingTypes Enumeration

Supported MIME Encoding types

[Visual Basic]
Public Enum EncodingTypes
[C#]
public enum EncodingTypes

Members

Member Name | Description
QUOTED_PRINTABLE | Quoted printable encoding
_7BIT | 7 bit encoding (default)
BASE64 | Base64 encoding

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpDotNet Namespace


MessagePriorityTypes Enumeration

The three message priority types

[Visual Basic]
Public Enum MessagePriorityTypes
[C#]
public enum MessagePriorityTypes

Members

Member Name | Description
LOW | Low priority
NORMAL | Normal priority (default)
HIGH | High priority

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpDotNet Namespace


ReturnCodes Enumeration

Return codes from the object

[Visual Basic]
Public Enum ReturnCodes
[C#]
public enum ReturnCodes

Members

Member Name | Description
SUCCESS | General success
FAILURE_GENERAL | General failure
FAILURE_SOCKET_ERROR | An unrecoverable socket error occurred.
FAILURE_INITIALIZE_LOG_FILE | Failed to initialize the log file, cannot continue.
FAILURE_NEEDS_TO_EMAIL_ADDRESS | The "to" email address is missing.
FAILURE_NEEDS_FROM_EMAIL_ADDRESS | The "from" email address is missing.
FAILURE_LOAD_BODY_URL | Cannot load the url specified
FAILURE_LOAD_BODY_FROM_FILE | Cannot load message body from file.
FAILURE_SMTP_INITIALIZE | Could not initialize the SMTP server connection
FAILURE_CONNECT | Failed to connect to the specified server(s)
FAILURE_AUTHENTICATE | Failed to authenticate
FAILURE_DISCONNECT | Failed to disconnected from the SMTP server.
FAILURE_PREPARE | Failed to prepare (address) the message.
FAILURE_SEND_MESSAGE | Failed to send the message
FAILURE_TIMEOUT | Operation timed out.
FAILURE_ALTERNATE_BODY | There was a problem with the alternate body message.
FAILURE_CREATE_TEMPORARY_DIRECTORY | Failed to create a temporary directory under the TempDirectory.
FAILURE_NEEDS_SERVER_ADDRESS | Failed to connect to mail server because specified ServerAddress is blank.
FAILURE_LOGIN | Failed to log in to the mail server.
FAILURE_NOT_CONNECTED | General failure because not logged connceted.
FAILURE_REGISTRY_ACCESS | Cannot read/write/create keys or values in the System Registry.
FAILURE_ADD_ATTACHMENT | Cannot add the specified attachment.

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpDotNet Namespace


SmtpServer Class

The main class for SmtpDotNet.

For a list of all members of this type, see SmtpServer Members.

System.Object
CoreServer
SmtpServer

[Visual Basic]
Public Class SmtpServer
Inherits CoreServer
[C#]
public class SmtpServer : CoreServer

Requirements

Namespace: SmtpDotNet Namespace

Assembly: SmtpDotNet.dll

See Also

SmtpServer Members | SmtpDotNet Namespace


SmtpServer Members

Public Static (Shared) Methods

GetWebPageHtml | Downloads the specified URL and puts HTML into a string buffer.
SendQuick | Sends simple message that does not allow any other parameters or properties to be set.
Version | Specifies the current version of the SmtpDotNet assembly.

Public Instance Constructors

SmtpServer Overloaded. Initialize a new instance of the SmtpServer class.

Public Instance Properties

AltBody | An alternate message body displayed in older mail readers that cannot display html formatted messages. Specify this propery only when specifying an HTML formatted message.
AltBodyFile | Specifies a file to load the alternate body of the message from.
AltBodyUrl | Specifies a URL to load the alternate body of the message from.
AppendLogFile | Specifies whether to append the log if it already exists.
AuthLogin | The mail server authentication login. Some mail servers require that the user log in before sending messages.
AuthPassword | The mail server authenticaton password. Requires AuthLogin.
AutoNameLogFile | Specifies whether Smtp.NET should automatically choose a random name for the log file.
BCCAddress | The BCC email address.
Body | The main message body. This can be plain text, or html text.
BodyFile | Specifies a file name to load the body of the message from.
BodyFileFormat | The format of the message body loaded from a file using the BodyFile property.
BodyFormat | The format of the message body.
BodyUrl | Specifies a URL to load the body of the message from.
CCAddress | The CC email address.
CCFriendly | The message CC "friendly" name. Instead of the CC email address being displayed in the recipient's email reader program, the "friendly" name is displayed.
CharsPerLine | Specifies the number of Characeters per line in a MIME part.
ConnectionRetries | Specifies the number of additional times a connection should be attempted upon intial connection failure.
ConnectionRetryDelay | Specifies the number of milliseconds to wait between retries of failed connection to the mail server.
ContentTransferEncoding | Specifies the content-transfer-encoding to use for the message body.
DBDataTable | A datatable that contains data to use with the MailMerge or Send methods.
DBEmailColumn | The name of the column in the data table that contains email addresses.
DBFriendlyColumn | The name of the column in the data table that holds a friendly name for the recipient.
DBRecipientLimit | Specifies the maximum number of recipients that can be addressed per message.
DBRecipientType | The recipient type for the addresses in the DBDataTable of enumerated type AddressTypes.
EmailCountBad | Returns the number of email addresses that were rejected by the mail server for mail delivery.
EmailCountGood | Returns the number email addresses that were accepted by the mail server for mail delivery
EmailReport A DataSet that contains two tables: "good" and "bad"
  • The "good" table contains email addresses that were accepted by the email server.
  • The "bad" table contains email addresses that were NOT accepted by the email server.
EmbedImages | Specifies whether to embed images in an HTML formatted message.
FromAddress | The message FROM address
FromFriendly | The message FROM "friendly" name. Instead of the FROM email address being displayed in the recipient's email reader program, the "friendly" name is displayed.
Header | Allows additional mail header information
InMemoryLog | Specifies whether to log all events to an in-memory buffer instead of a file
LastError | Returns the last error encountered.
LastErrorCollection | Returns a string collection of all of the error messages in order. Useful for tracing.
LogExceptions | Specifies whether to log exceptions. Useful to debug problems with Smtp.NET or connectivitiy with a mail server.
LogFilename | The fully qualified pathname of the log file.
LogMailServerMessages | Enables or disables logging of SMTP debug messages including all socket messages to and from an SMTP mail server.
MessagePriority | The message prority
PickupDirectory | Specifies the IIS/Exchange Pickup directory to drop queued email messages into.
Port | SMTP mail server port number. The default is 25.
QueueDateTime | Specifies the date and time that messages queued for delivery using should be sent.
QueueDirectory | Specifies the queue directory. The default is c:\temp\emailQ
QueueFilenames | A StringCollection object containing the fully qualified pathname(s) of the files crated for the queue.
RandomObject | An object of class Random that is used to ensure uniqueness with Smtp.NET and emailQ.NET queueing. Specifically important if using Smtp.NET in a multithreaded environment.
ReadReceiptFrom | Email address to send the read receipt to
ReadReceiptFromFriendly | Friendly name to send the read receipt to
ReplyToAddress | Specifies the reply-to address
ReplyToFriendly | Specifies the friendly name for the reply-to address.
SendDelay | Specifies the amount of time in milliseconds to wait before sending the next email message.
SendToPickupDirectory | Specifies whether to create a "eml" file that is recognized by IIS/Exchange Smtp Server.
SendToQueue | Specifies whether to send messages to emailQ.
ServerAddress | SMTP mail server addresses, e.g. mail.domain.com or 192.0.0.1. Separate multiple servers with a comma, e.g. mail.domain.com,192.0.0.1,localhost, etc.
Subject | The message subject.
TempDirectory | Temporary directory for storing images and files downloaded using the html formatted messaging features AND the directory used when the AutoNameLogFile property is set to true.
TestMode | Enables or disables test mode. If test mode is turned on, calling the Send method, the mail message is prepared, the mail server is connected to, but the message is never actually sent.
TimeoutConnect | Specifies the Connection timeout in milliseconds.
TimeoutGeneral | Specifies the General timeout in milliseconds.
ToAddress | The TO email address.
ToFriendly | The message TO "friendly" name. Instead of the TO email address being displayed in the recipient's email reader program, the "friendly" name is displayed.
ZipAttachments | Specifies whether to zip compress attachments automatically.
ZipCompressionLevel | Sets the Zip compression level
ZipFilename | Specifies the name of the zip file, which all of the attachments are compressed into. This is the name of the file seen in the email client when the email is opened.

Public Instance Methods

AddAttachment | Overloaded. Adds an attachment to the current message
AddRecipient | Overloaded. Add a recipient to the mail message.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
LogFileToString | Returns the current log file as a string.
MailMerge | Combines data from the DBDataTable with various properties in the message.
SaveInMemoryLog | Saves an in-memory log to a physical file as specified by LogFilename
Send | Overloaded. Send the message.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

SmtpServer Class | SmtpDotNet Namespace


SmtpServer Constructor

Main Constructor to initialize the class.

Overload List

Main Constructor to initialize the class.

public SmtpServer();

Main Constructor to initialize the class, with a log file name specified.

public SmtpServer(string);

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | LogFilename


SmtpServer Constructor ()

Main Constructor to initialize the class.

[Visual Basic]
Overloads Public Sub New()
[C#]
public SmtpServer();

Remarks

If using this constructor, the log filename is not set. Therefore, if you wish to have a log file created, you must set the LogFilename property before calling any other method.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer Constructor Overload List | LogFilename


SmtpServer Constructor (String)

Main Constructor to initialize the class, with a log file name specified.

[Visual Basic]
Overloads Public Sub New( _
   ByVal logFilename As String _
)
[C#]
public SmtpServer(
string logFilename
);

Parameters

logFilename
Pathname of log file for messages.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer Constructor Overload List


SmtpServer Properties

The properties of the SmtpServer class are listed below. For a complete list of SmtpServer class members, see the SmtpServer Members topic.

Public Instance Properties

AltBody | An alternate message body displayed in older mail readers that cannot display html formatted messages. Specify this propery only when specifying an HTML formatted message.
AltBodyFile | Specifies a file to load the alternate body of the message from.
AltBodyUrl | Specifies a URL to load the alternate body of the message from.
AppendLogFile | Specifies whether to append the log if it already exists.
AuthLogin | The mail server authentication login. Some mail servers require that the user log in before sending messages.
AuthPassword | The mail server authenticaton password. Requires AuthLogin.
AutoNameLogFile | Specifies whether Smtp.NET should automatically choose a random name for the log file.
BCCAddress | The BCC email address.
Body | The main message body. This can be plain text, or html text.
BodyFile | Specifies a file name to load the body of the message from.
BodyFileFormat | The format of the message body loaded from a file using the BodyFile property.
BodyFormat | The format of the message body.
BodyUrl | Specifies a URL to load the body of the message from.
CCAddress | The CC email address.
CCFriendly | The message CC "friendly" name. Instead of the CC email address being displayed in the recipient's email reader program, the "friendly" name is displayed.
CharsPerLine | Specifies the number of Characeters per line in a MIME part.
ConnectionRetries | Specifies the number of additional times a connection should be attempted upon intial connection failure.
ConnectionRetryDelay | Specifies the number of milliseconds to wait between retries of failed connection to the mail server.
ContentTransferEncoding | Specifies the content-transfer-encoding to use for the message body.
DBDataTable | A datatable that contains data to use with the MailMerge or Send methods.
DBEmailColumn | The name of the column in the data table that contains email addresses.
DBFriendlyColumn | The name of the column in the data table that holds a friendly name for the recipient.
DBRecipientLimit | Specifies the maximum number of recipients that can be addressed per message.
DBRecipientType | The recipient type for the addresses in the DBDataTable of enumerated type AddressTypes.
EmailCountBad | Returns the number of email addresses that were rejected by the mail server for mail delivery.
EmailCountGood | Returns the number email addresses that were accepted by the mail server for mail delivery
EmailReport A DataSet that contains two tables: "good" and "bad"
  • The "good" table contains email addresses that were accepted by the email server.
  • The "bad" table contains email addresses that were NOT accepted by the email server.
EmbedImages | Specifies whether to embed images in an HTML formatted message.
FromAddress | The message FROM address
FromFriendly | The message FROM "friendly" name. Instead of the FROM email address being displayed in the recipient's email reader program, the "friendly" name is displayed.
Header | Allows additional mail header information
InMemoryLog | Specifies whether to log all events to an in-memory buffer instead of a file
LastError | Returns the last error encountered.
LastErrorCollection | Returns a string collection of all of the error messages in order. Useful for tracing.
LogExceptions | Specifies whether to log exceptions. Useful to debug problems with Smtp.NET or connectivitiy with a mail server.
LogFilename | The fully qualified pathname of the log file.
LogMailServerMessages | Enables or disables logging of SMTP debug messages including all socket messages to and from an SMTP mail server.
MessagePriority | The message prority
PickupDirectory | Specifies the IIS/Exchange Pickup directory to drop queued email messages into.
Port | SMTP mail server port number. The default is 25.
QueueDateTime | Specifies the date and time that messages queued for delivery using should be sent.
QueueDirectory | Specifies the queue directory. The default is c:\temp\emailQ
QueueFilenames | A StringCollection object containing the fully qualified pathname(s) of the files crated for the queue.
RandomObject | An object of class Random that is used to ensure uniqueness with Smtp.NET and emailQ.NET queueing. Specifically important if using Smtp.NET in a multithreaded environment.
ReadReceiptFrom | Email address to send the read receipt to
ReadReceiptFromFriendly | Friendly name to send the read receipt to
ReplyToAddress | Specifies the reply-to address
ReplyToFriendly | Specifies the friendly name for the reply-to address.
SendDelay | Specifies the amount of time in milliseconds to wait before sending the next email message.
SendToPickupDirectory | Specifies whether to create a "eml" file that is recognized by IIS/Exchange Smtp Server.
SendToQueue | Specifies whether to send messages to emailQ.
ServerAddress | SMTP mail server addresses, e.g. mail.domain.com or 192.0.0.1. Separate multiple servers with a comma, e.g. mail.domain.com,192.0.0.1,localhost, etc.
Subject | The message subject.
TempDirectory | Temporary directory for storing images and files downloaded using the html formatted messaging features AND the directory used when the AutoNameLogFile property is set to true.
TestMode | Enables or disables test mode. If test mode is turned on, calling the Send method, the mail message is prepared, the mail server is connected to, but the message is never actually sent.
TimeoutConnect | Specifies the Connection timeout in milliseconds.
TimeoutGeneral | Specifies the General timeout in milliseconds.
ToAddress | The TO email address.
ToFriendly | The message TO "friendly" name. Instead of the TO email address being displayed in the recipient's email reader program, the "friendly" name is displayed.
ZipAttachments | Specifies whether to zip compress attachments automatically.
ZipCompressionLevel | Sets the Zip compression level
ZipFilename | Specifies the name of the zip file, which all of the attachments are compressed into. This is the name of the file seen in the email client when the email is opened.

See Also

SmtpServer Class | SmtpDotNet Namespace


SmtpServer.AltBody Property

An alternate message body displayed in older mail readers that cannot display html formatted messages. Specify this propery only when specifying an HTML formatted message.

[Visual Basic]
Public Property AltBody As String
[C#]
public string AltBody {get; set;}

Property Value

A string that is the alternate body.

Remarks

If the message body is not HTML, then the setting this property will have no effect because the message body will override the alternate body.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the alternate message body
                 oSmtpDotNet.AltBody = "To view this message, visit our website.";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set the alternate message body
                 oSmtpDotNet.AltBody = "To view this message, visit our website."

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | CCAddress


SmtpServer.AltBodyFile Property

Specifies a file to load the alternate body of the message from.

[Visual Basic]
Public Property AltBodyFile As String
[C#]
public string AltBodyFile {get; set;}

Property Value

A string that contains the fully qualified pathname that the body of the message is loaded from.

Remarks

If the file does not exist, an error will be returned and processing will stop. If the message body is not HTML, then the setting this property will have no effect because the message body will override the alternate body.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the alternate message body to the contents (html) found
                 // in the file C:\\temp\\body.txt
                 oSmtpDotNet.AltBodyFile = "C:\\temp\\body.txt";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Set the alternate message body to the contents (html) found
                 ' in the file C:\temp\body.txt
                 oSmtpDotNet.AltBodyFile = "C:\temp\body.txt"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.AltBodyUrl Property

Specifies a URL to load the alternate body of the message from.

[Visual Basic]
Public Property AltBodyUrl As String
[C#]
public string AltBodyUrl {get; set;}

Property Value

A string that contains a URL to load the alternate message body from.

Remarks

The web page loaded with this property should not contain html since the alternate body is intended for plain text only. If the URL cannot be loaded, an error will be returned and processing will stop. If the message body is not HTML, then the setting this property will have no effect because the message body will override the alternate body.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the alternate message body to the contents (html) found
                 // at http://www.yahoo.com
                 oSmtpDotNet.AltBodyUrl = "http://www.yahoo.com";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Set the alternate message body to the contents (html) found
                 ' at http://www.yahoo.com
                 oSmtpDotNet.AltBodyUrl = "http://www.yahoo.com"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.AppendLogFile Property

Specifies whether to append the log if it already exists.

[Visual Basic]
Public Property AppendLogFile As Boolean
[C#]
public bool AppendLogFile {get; set;}

Property Value

True or False. The default value is false.

Remarks

If true, the log, will be appended to. If false, the log will be deleted and re-created. This applies to physical (file) logs and to in-memory logs.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 oSmtpDotNet.LogFilename = "c:\log.txt";
                 // Append the log file, if it already exists
                 oSmtpDotNet.AppendLogFile = true;

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 oSmtpDotNet.LogFilename = "c:\log.txt"
                 ' Append the log file, if it already exists
                 oSmtpDotNet.AppendLogFile = true

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | LogFilename


SmtpServer.AuthLogin Property

The mail server authentication login. Some mail servers require that the user log in before sending messages.

[Visual Basic]
Public Property AuthLogin As String
[C#]
public string AuthLogin {get; set;}

Property Value

A string that contains the login for an SMTP server.

Remarks

If you encounter an error with the mail server that prevents sending of a message, try this property.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the log authentication login AND password
                 oSmtpDotNet.AuthLogin = "username";
                 oSmtpDotNet.AuthPassword = "secret";

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the log authentication login AND password
                 oSmtpDotNet.AuthLogin = "username"
                 oSmtpDotNet.AuthPassword = "secret"

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AuthPassword


SmtpServer.AuthPassword Property

The mail server authenticaton password. Requires AuthLogin.

[Visual Basic]
Public Property AuthPassword As String
[C#]
public string AuthPassword {get; set;}

Property Value

A string that contains the password for the supplied AuthLogin.

Remarks

Requires the AuthLogin property to be set.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the log authentication login AND password
                 oSmtpDotNet.AuthLogin = "username";
                 oSmtpDotNet.AuthPassword = "secret";

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the log authentication login AND password
                 oSmtpDotNet.AuthLogin = "username"
                 oSmtpDotNet.AuthPassword = "secret"

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AuthLogin


SmtpServer.AutoNameLogFile Property

Specifies whether Smtp.NET should automatically choose a random name for the log file.

[Visual Basic]
Public Property AutoNameLogFile As Boolean
[C#]
public bool AutoNameLogFile {get; set;}

Property Value

If true, the log file is created using a unique name in the path specified with the TempDirectory property. If false, the log file is not automatically generated.

Remarks

The automatically named log file is placed in the temporary directory set with the TempDirectory property. The name of the log file can be retrieved, after the Send or MailMerge method is called, with the LogFilename property. Setting this property overrides value specified with LogFilename property or the log filename specified in the constructor of the SmtpServer class.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Make the object create a unique log file name
                 oSmtpDotNet.AutoNameLogFile = true;

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");

                 // Display the log filename
                 Console.WriteLine(oSmtpDotNet.Logfilename);
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Make the object create a unique log file name
                 oSmtpDotNet.AutoNameLogFile = true

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")

                 ' Display the log filename
                 Console.WriteLine(oSmtpDotNet.Logfilename)
            End Function

[C#]
            bool bAutoNameLogFile = oSmtpDotNet.AutoNameLogFile;
            oSmtpDotNet.AutoNameLogFile = true;

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.BCCAddress Property

The BCC email address.

[Visual Basic]
Public Property BCCAddress As String
[C#]
public string BCCAddress {get; set;}

Property Value

A string that is an email address for blind carbon copy.

Remarks

This property is intended for one bcc email address. If addressing multiple bcc email addresses, use AddRecipient.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set a "bcc" address
                 oSmtpDotNet.BCCAddress = "email@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set a "bcc" address
                 oSmtpDotNet.BCCAddress = "email@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AddRecipient


SmtpServer.Body Property

The main message body. This can be plain text, or html text.

[Visual Basic]
Public Property Body As String
[C#]
public string Body {get; set;}

Property Value

A string that is the message body.

Remarks

If specifying a HTML, you must set the BodyFormatType to HTML in order for the message to appear as HTML in the client's email reader.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | BodyFormat


SmtpServer.BodyFile Property

Specifies a file name to load the body of the message from.

[Visual Basic]
Public Property BodyFile As String
[C#]
public string BodyFile {get; set;}

Property Value

A string that specifies the fully qualified pathname of a file to load the body of the message from.

Remarks

The file can contain either plain text or html. If html is specified, use the BodyFileFormat property to specify that the message is HTML.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the subject
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the message body to the contents (html) found
                 // in the file c:\temp\page.html
                 oSmtpDotNet.BodyFile = "c:\\temp\\page.html";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the subject
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set the message body to the contents (html) found
                 ' in the file c:\temp\page.html
                 oSmtpDotNet.BodyFile = "c:\temp\page.html"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | BodyFileFormat


SmtpServer.BodyFileFormat Property

The format of the message body loaded from a file using the BodyFile property.

[Visual Basic]
Public Property BodyFileFormat As BodyFormatTypes
[C#]
public BodyFormatTypes BodyFileFormat {get; set;}

Property Value

An enumerated integer value of type BodyFormatTypes as defined in SmtpDotNet.Definitions namespace.

Remarks

Specify either: BodyFormatTypes.PLAIN or BodyFormatTypes.HTML

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Force the message body to be encoded as HTML
                 oSmtpDotNet.BodyFileFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Force the message body to be encoded as HTML
                 oSmtpDotNet.BodyFileFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.BodyFormat Property

The format of the message body.

[Visual Basic]
Public Property BodyFormat As BodyFormatTypes
[C#]
public BodyFormatTypes BodyFormat {get; set;}

Property Value

An enumerated integer value of type BodyFormatTypes as defined in SmtpDotNet.Definitions namespace.

Remarks

Specify either: BodyFormatTypes.PLAIN or BodyFormatTypes.HTML

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | Body | BodyFormatTypes


SmtpServer.BodyUrl Property

Specifies a URL to load the body of the message from.

[Visual Basic]
Public Property BodyUrl As String
[C#]
public string BodyUrl {get; set;}

Property Value

A string that is a URL to load the body of the message from.

Remarks

This property must be set to a valid URL that is of protocol "http://". Limitations:

  1. "You cannot use the "file:" protocol.
  2. The content type is always set to TEXT/HTML.
  3. Shockwave files are not guaranteed to be viewable in the client browser.
  4. Urls that redirect to another directory or site may cause broken images. Be sure to not specify URLs that may redirect.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the subject
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the message body to the contents (html) found
                 // at http://www.ExclamationSoft.com
                 oSmtpDotNet.BodyUrl = "http://www.ExclamationSoft.com";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the subject
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set the message body to the contents (html) found
                 ' at http://www.ExclamationSoft.com
                 oSmtpDotNet.BodyUrl = "http://www.ExclamationSoft.com"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.CCAddress Property

The CC email address.

[Visual Basic]
Public Property CCAddress As String
[C#]
public string CCAddress {get; set;}

Property Value

A string that is an email address for carbon copy.

Remarks

This property is intended for one cc email address. If addressing multiple cc email addresses, use AddRecipient.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set a "cc" address
                 oSmtpDotNet.CCAddress = "email@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set a "cc" address
                 oSmtpDotNet.CCAddress = "email@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AddRecipient | CCFriendly


SmtpServer.CCFriendly Property

The message CC "friendly" name. Instead of the CC email address being displayed in the recipient's email reader program, the "friendly" name is displayed.

[Visual Basic]
Public Property CCFriendly As String
[C#]
public string CCFriendly {get; set;}

Property Value

A string that specifies a friendly name to display in place of the email address in an email reader.

Remarks

Not all SMTP servers support this feature.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set a "cc" address AND friendly name
                 oSmtpDotNet.CCAddress = "email@domain.com";
                 oSmtpDotNet.CCFriendly =  "John Doe";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set a "cc" address AND friendly name
                 oSmtpDotNet.CCAddress = "email@domain.com"
                 oSmtpDotNet.CCFriendly =  "John Doe"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | CCAddress


SmtpServer.CharsPerLine Property

Specifies the number of Characeters per line in a MIME part.

[Visual Basic]
Public Property CharsPerLine As UInt32
[C#]
public uint CharsPerLine {get; set;}

Property Value

An integer value. The default value is 76.

Remarks

This value should only be changed to accomodate older mail servers.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Set maximum characters per line
                 oSmtpDotNet.CharsPerLine = 78;

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set maximum characters per line
                 oSmtpDotNet.CharsPerLine = 78

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.ConnectionRetries Property

Specifies the number of additional times a connection should be attempted upon intial connection failure.

[Visual Basic]
Public Property ConnectionRetries As Integer
[C#]
public int ConnectionRetries {get; set;}

Property Value

An integer value greater than or equal to 0. The default value is 3.

Remarks

This property must be set before calling the Send or MailMerge methods.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Set the number of times to retry a connection if failed.
                 oSmtpDotNet.ConnectionRetries = 5;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                       Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the number of times to retry a connection if failed.
                 oSmtpDotNet.ConnectionRetries = 5

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.ConnectionRetryDelay Property

Specifies the number of milliseconds to wait between retries of failed connection to the mail server.

[Visual Basic]
Public Property ConnectionRetryDelay As Integer
[C#]
public int ConnectionRetryDelay {get; set;}

Property Value

An integer value greater than or equal to 1. The default value is 3000.

Remarks

This property must be set before calling the Send or MailMerge methods.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Set the number of times to retry a connection if failed.
                 oSmtpDotNet.ConnectionRetries = 5;
                 oSmtpDotNet.ConnectionRetryDelay = 5000; // 5 second delay

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                       Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the number of times to retry a connection if failed.
                 oSmtpDotNet.ConnectionRetries = 5
                 oSmtpDotNet.ConnectionRetryDelay = 5000 // 5 second delay

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ConnectionRetries


SmtpServer.ContentTransferEncoding Property

Specifies the content-transfer-encoding to use for the message body.

[Visual Basic]
Public Property ContentTransferEncoding As EncodingTypes
[C#]
public EncodingTypes ContentTransferEncoding {get; set;}

Property Value

An enumerated type of EncodingTypess. The default is QUOTED-PRINTABLE. Other valid values are _7Bit

Remarks

Values specified other than "QUOTED-PRINTABLE" or "_7Bit" will be ignored and the default used.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Force the message body to be html
                 oSmtpDotNet.ContentTransferEncoding = EncodingTypes.7BIT;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Force the message body to be html
                 oSmtpDotNet.ContentTransferEncoding = EncodingTypes.7BIT

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | Body | BodyFormatTypes


SmtpServer.DBDataTable Property

A datatable that contains data to use with the MailMerge or Send methods.

[Visual Basic]
Public Property DBDataTable As DataTable
[C#]
public System.Data.DataTable DBDataTable {get; set;}

Property Value

A datatable

Remarks

If you specify a value for this property, that is not null, and a call to the Send method is made, the component will attempt to address the message using that data. If a value is specified for this property and the method MailMerge is called, it's value will be overwritten because the MailMerge method expects a DataSet as one of its parameters.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the DBDataTable to an object that is of type DataTable
                 oSmtpDotNet.DBDataTable = myDataTable;

                 // Set other DB properties
                 oSmtpDotNet.DBRecipientType = AddressTypes.TO;
                 oSmtpDotNet.DBEmailColumn = "email";
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the DBDataTable to an object that is of type DataTable
                 oSmtpDotNet.DBDataTable = myDataTable

                 oSmtpDotNet.DBRecipientType = AddressTypes.TO
                 ' Set other DB properties
                 oSmtpDotNet.DBEmailColumn = "email"
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | DataTable | DBEmailColumn | DBFriendlyColumn | DBRecipientLimit | DBRecipientType


SmtpServer.DBEmailColumn Property

The name of the column in the data table that contains email addresses.

[Visual Basic]
Public Property DBEmailColumn As String
[C#]
public string DBEmailColumn {get; set;}

Property Value

A string of the name of the column in the DataTable that contains email addresses.

Remarks

If you specify a value for this property, that is not null, and a call to the Send method is made, the component will attempt to address the message using data from the field as specified from this property. If a value is specified for this property and the method MailMerge is called, it's value will be overwritten if a value other than null is specified for the emailColumn parameter of the MailMerge method.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the email column property
                 oSmtpDotNet.DBEmailColumn = "email";

                 // Set other DB properties
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName";
                 oSmtpDotNet.DBDataTable = myDataTable;

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the email column property
                 oSmtpDotNet.DBEmailColumn = "email"

                 ' Set other DB properties
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName"
                 oSmtpDotNet.DBDataTable = myDataTable

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | DBDataTable | DBFriendlyColumn | DBRecipientLimit | DBRecipientType


SmtpServer.DBFriendlyColumn Property

The name of the column in the data table that holds a friendly name for the recipient.

[Visual Basic]
Public Property DBFriendlyColumn As String
[C#]
public string DBFriendlyColumn {get; set;}

Property Value

A string

Remarks

Delimit multiple columns with a comma. For example, if the friendly name is contained in two columns, one named "first_name" and the second "last_name", set this property with "first_name,last_name". A space is automatically placed in between multiply specified columns.

For example, if you specify "first_name,last_name", the freindly name will appear as "John Doe" and not "JohnDoe"

For more control over this type of feature, use full mail merge.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the friendly column property
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName";

                 // Set other DB properties
                 oSmtpDotNet.DBDataTable = myDataTable;
                 oSmtpDotNet.DBEmailColumn = "email";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the friendly column property
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName"

                 ' Set other DB properties
                 oSmtpDotNet.DBDataTable = myDataTable
                 oSmtpDotNet.DBEmailColumn = "email"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | DBDataTable | DBEmailColumn | DBRecipientLimit | DBRecipientType


SmtpServer.DBRecipientLimit Property

Specifies the maximum number of recipients that can be addressed per message.

[Visual Basic]
Public Property DBRecipientLimit As Integer
[C#]
public int DBRecipientLimit {get; set;}

Property Value

The default value is 100. An integer greater than 0.

Remarks

Most mail servers limit the number of email addresses that a message is addressed to. This is to prevent overloading the mail server and is also a standard. If you receive the error message from your mail server: "Too many recipients", try setting this property to a lower number.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Set the limit per message sent to 5.
                 oSmtpDotNet.DBRecipientLimit = 5;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the limit per message sent to 5.
                 oSmtpDotNet.DBRecipientLimit = 5

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | DBDataTable | DBEmailColumn | DBFriendlyColumn | DBRecipientType


SmtpServer.DBRecipientType Property

The recipient type for the addresses in the DBDataTable of enumerated type AddressTypes.

[Visual Basic]
Public Property DBRecipientType As AddressTypes
[C#]
public AddressTypes DBRecipientType {get; set;}

Property Value

An integer value of enumerated type AddressTypes

Remarks

The default value is AddressTypes.TO.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the recipient type property
                 oSmtpDotNet.DBRecipientType = AddressTypes.TO;

                 // Set other DB properties
                 oSmtpDotNet.DBEmailColumn = "email";
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName";
                 oSmtpDotNet.DBDataTable = myDataTable;

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the recipient type property
                 oSmtpDotNet.DBRecipientType = AddressTypes.TO

                 ' Set other DB properties
                 oSmtpDotNet.DBEmailColumn = "email"
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName"
                 oSmtpDotNet.DBDataTable = myDataTable

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AddressTypes | DBDataTable | DBEmailColumn | DBFriendlyColumn | DBRecipientLimit


SmtpServer.EmailCountBad Property

Returns the number of email addresses that were rejected by the mail server for mail delivery.

[Visual Basic]
Public Property EmailCountBad As UInt32
[C#]
public uint EmailCountBad {get; set;}

Property Value

An unsigned integer value of the number of email addresses rejected by the mail server.

Remarks

This property can be set if you wish to increment from a previous value.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Display the number of bad email addresses.
                 Console.WriteLine(oSmtpDotNet.EmailCountBad);

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Display the number of bad email addresses
                 Console.WriteLine(oSmtpDotNet.EmailCountBad)

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | EmailCountGood


SmtpServer.EmailCountGood Property

Returns the number email addresses that were accepted by the mail server for mail delivery

[Visual Basic]
Public Property EmailCountGood As UInt32
[C#]
public uint EmailCountGood {get; set;}

Property Value

A unsigned integer value of the number of email addresses

Remarks

This property can be set if you wish to increment from a previous value.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Display the number of good email addresses.
                 Console.WriteLine(oSmtpDotNet.EmailCountGood);

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Display the number of good email addresses
                 Console.WriteLine(oSmtpDotNet.EmailCountGood)

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | EmailCountBad


SmtpServer.EmailReport Property

A DataSet that contains two tables: "good" and "bad"

  • The "good" table contains email addresses that were accepted by the email server.
  • The "bad" table contains email addresses that were NOT accepted by the email server.

[Visual Basic]
Public ReadOnly Property EmailReport As DataSet
[C#]
public System.Data.DataSet EmailReport {get;}

Remarks

This property is useful for recovery in the event of a catastrophic failure. The "bad" email addresses could also be for removal of those addresses from your list/database. This is not a email address validation feature, but rather a collection of email addresses that are accepted or rejected by the sending mail server.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                       Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");

               // Use the email report
               DataTable oGood = new DataTable();
               oGood = EmailReport.Tables["good"];
               DataTable oBad = new DataTable();
               oBad = EmailReport.Tables["bad"];

            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")

               ' Use the EmailReport property
               Dim oGood As New DataTable()
               oGood = oSmtpDotNet.EmailReport.Tables("good")
               Dim oBad As New DataTable()
               oBad = oSmtpDotNet.EmailReport.Tables("bad")

            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | Send


SmtpServer.EmbedImages Property

Specifies whether to embed images in an HTML formatted message.

[Visual Basic]
Public Property EmbedImages As Boolean
[C#]
public bool EmbedImages {get; set;}

Property Value

If true, images will be downloaded and embedded into the message. If false, images will be referenced by the fully qualified URL.

Remarks

This property only applies when the BodyUrl property is used.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the subject
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the message body to the contents (html) found
                 // at http://www.ExclamationSoft.com AND embed the images
                 oSmtpDotNet.BodyUrl = "http://www.ExclamationSoft.com";
                 oSmtpDotNet.EmbedImages = true;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the subject
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set the message body to the contents (html) found
                 ' at http://www.ExclamationSoft.com AND embed the images
                 oSmtpDotNet.BodyUrl = "http://www.ExclamationSoft.com"
                 oSmtpDotNet.EmbedImages = true

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | BodyUrl


SmtpServer.FromAddress Property

The message FROM address

[Visual Basic]
Public Property FromAddress As String
[C#]
public string FromAddress {get; set;}

Property Value

A string that is the from email address.

Remarks

This is a required property when calling the Send or MailMerge methods.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | FromFriendly


SmtpServer.FromFriendly Property

The message FROM "friendly" name. Instead of the FROM email address being displayed in the recipient's email reader program, the "friendly" name is displayed.

[Visual Basic]
Public Property FromFriendly As String
[C#]
public string FromFriendly {get; set;}

Property Value

A string that specifies a friendly name to display in place of the email address in a email reader.

Remarks

Not all SMTP servers support this feature.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the friendly from name
                 oSmtpDotNet.FromFriendly =  "John Doe";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the friendly from name
                 oSmtpDotNet.FromFriendly =  "John Doe"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | FromAddress


SmtpServer.Header Property

Allows additional mail header information

[Visual Basic]
Public Property Header As String
[C#]
public string Header {get; set;}

Property Value

A string that appended to the message header.

Remarks

Incorrect header name value pairs may cause message delivery failure.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Add a custom header value
                 oSmtpDotNet.Header =  "X-Something: value";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Add a custom header value
                 oSmtpDotNet.Header =  "X-Something: value"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.InMemoryLog Property

Specifies whether to log all events to an in-memory buffer instead of a file

[Visual Basic]
Public Property InMemoryLog As Boolean
[C#]
public bool InMemoryLog {get; set;}

Property Value

True or False. The default is false.Boolean value: true or false

Remarks

If true, then all events are logged in memory which can be more efficient than logging to a file.

The in-memory log can be accessed with the LogFileToString method or the SaveInMemoryLog method.

It is not recommended to use this feature if sending to a large number of recipients since it will increase the memory usage of Smtp.NET which may lead to system performance problems.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Log messages to an in-memory buffer.
                 oSmtpDotNet.InMemoryLog = true;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Log messages to an in-memory buffer.
                 oSmtpDotNet.InMemoryLog = True

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | LogFilename | LogFileToString | SaveInMemoryLog


SmtpServer.LastError Property

Returns the last error encountered.

[Visual Basic]
Public ReadOnly Property LastError As String
[C#]
public string LastError {get;}

Property Value

A string that contains the last error message encountered.

Remarks

If there are no error messages, the string returned is null.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | LastErrorCollection


SmtpServer.LastErrorCollection Property

Returns a string collection of all of the error messages in order. Useful for tracing.

[Visual Basic]
Public ReadOnly Property LastErrorCollection As ErrorCollection
[C#]
public Utility.ErrorCollection LastErrorCollection {get;}

Property Value

Contains a ErrorCollection object

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError)
                      // Write out the log file contents
                      Console.WriteLine(oSmtpDotNet.LogFileToString(False));

                   // The following example concatonates a string with all of the
                   // strings in the LastErrorCollection.
                   string sErrorList = null;
                   foreach ( string sError in oSmtpServer.LastErrorCollection )
                   {
                        sErrorList += sError;
                   }
                   Console.WriteLine(sErrorList);
                     return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                      ' A problem occurred.
                      ' Write out the last error encountered
                      Console.WriteLine(oSmtpDotNet.LastError)
                      ' Write out the log file contents
                      Console.WriteLine(oSmtpDotNet.LogFileToString(False))

                   ' The following example concatonates a string with all of the
                   ' strings in the LastErrorCollection.
                   string sErrorList = null
                   foreach ( string sError in oSmtpServer.LastErrorCollection )
                   {
                        sErrorList += sError
                   }
                   Console.WriteLine(sErrorList)
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | LastError


SmtpServer.LogExceptions Property

Specifies whether to log exceptions. Useful to debug problems with Smtp.NET or connectivitiy with a mail server.

[Visual Basic]
Public Property LogExceptions As Boolean
[C#]
public bool LogExceptions {get; set;}

Property Value

If true, exceptions are logged to the file specified with the LogFilename Property. If false , exceptions are not logged.

Remarks

Requires Logging. This property will log all internal exceptions and errors to the log.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Write exceptions, if they occur, to the log.
                 oSmtpDotNet.LogExceptions = true;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                       Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Write exceptions, if they occur, to the log.
                 oSmtpDotNet.LogExceptions = True

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | LogFilename | LogMailServerMessages


SmtpServer.LogFilename Property

The fully qualified pathname of the log file.

[Visual Basic]
Public Property LogFilename As String
[C#]
public string LogFilename {get; set;}

Property Value

A string that specifies the fully qualified pathname of the log file.

Remarks

If the file exists, the object will try to delete and create the file unless the AppendLogFile property is set to true. If this property is either blank or null, the log file will not be created, unless the AutoNameLogFile property is set to true.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the log filename
                 oSmtpDotNet.LogFilename = "c:\temp\log.txt";

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the log filename
                 oSmtpDotNet.LogFilename = "c:\temp\log.txt"

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AutoNameLogFile | AppendLogFile


SmtpServer.LogMailServerMessages Property

Enables or disables logging of SMTP debug messages including all socket messages to and from an SMTP mail server.

[Visual Basic]
Public Property LogMailServerMessages As Boolean
[C#]
public bool LogMailServerMessages {get; set;}

Property Value

If true, all communication between the mail server and the object are logged. If false , then no messages are logged.

Remarks

Smtp message are only logged to the log file. This property requires either LogFilename to be set to a valid filename or AutoNameLogFile to be set to true, or InMemoryLog to be set to true.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Log messages from the mail server.
                 oSmtpDotNet.LogMailServerMessages = true;
                 // Set In Memory Log to true so that the messages can be stored.
                 oSmtpDotNet.InMemoryLog = true;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                       Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Log messages from the mail server.
                 oSmtpDotNet.LogMailServerMessages = True
                 ' Set In Memory Log to true so that the messages can be stored.
                 oSmtpDotNet.InMemoryLog = true;

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | LogFilename | AutoNameLogFile | InMemoryLog


SmtpServer.MessagePriority Property

The message prority

[Visual Basic]
Public Property MessagePriority As MessagePriorityTypes
[C#]
public MessagePriorityTypes MessagePriority {get; set;}

Property Value

An enumerated integer value of type MessagePriorityTypes as defined in SmtpDotNet.Definitions namespace.

Remarks

The default message priority is MessagePriorityTypes.NORMAL.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the message priority
                 oSmtpDotNet.MessagePriority = MessagePriorityTypes.HIGH;

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set the message priority
                 oSmtpDotNet.MessagePriority = MessagePriorityTypes.HIGH

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | MessagePriorityTypes


SmtpServer.PickupDirectory Property

Specifies the IIS/Exchange Pickup directory to drop queued email messages into.

[Visual Basic]
Public Property PickupDirectory As String
[C#]
public string PickupDirectory {get; set;}

Property Value

A string value. The default value is null.

Remarks

The best location is the "pickup" directory where IIS/Exchange can easily pickup and handle email delivery. This property requires the SendToPickupDirectory property to be set to True.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Send Messages to the Pickup Directory
                 oSmtpDotNet.SendToPickupDirectory = true;
                 oSmtpDotNet.PickupDirectory = "C:\\Inetpub\\mailroot\\Pickup";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Send Messages to the Pickup Directory
                 oSmtpDotNet.SendToPickupDirectory = true
                 oSmtpDotNet.PickupDirectory = "C:\Inetpub\mailroot\Pickup"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SendToQueue | QueueDirectory | QueueDateTime | QueueFilenames | SendToPickupDirectory | RandomObject


SmtpServer.Port Property

SMTP mail server port number. The default is 25.

[Visual Basic]
Public Property Port As Integer
[C#]
public int Port {get; set;}

Property Value

An integer value greater than 1 and less than 65535.

Remarks

The default value is 25.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Set the port
                 oSmtpDotNet.Port = 8080;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the port
                 oSmtpDotNet.Port = 8080

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.QueueDateTime Property

Specifies the date and time that messages queued for delivery using should be sent.

[Visual Basic]
Public Property QueueDateTime As Date
[C#]
public System.DateTime QueueDateTime {get; set;}

Property Value

A DateTime value. The default value is null.

Remarks

If the value is null, it will be ignored and the current date and time will be used. This property requires the SendToQueue property to be set to True.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Send message to the Queue Directory
                 oSmtpDotNet.SendToQueue = true;
                 oSmtpDotNet.QueueDateTime = DateTime.Now;
                 oSmtpDotNet.QueueDirectory = "C:\\Temp";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Send message to the Queue Directory
                 oSmtpDotNet.SendToQueue = true
                 oSmtpDotNet.QueueDateTime = DateTime.Now
                 oSmtpDotNet.QueueDirectory = "C:\Temp"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | PickupDirectory | SendToQueue | QueueDirectory | QueueFilenames | SendToPickupDirectory | RandomObject


SmtpServer.QueueDirectory Property

Specifies the queue directory. The default is c:\temp\emailQ

[Visual Basic]
Public Property QueueDirectory As String
[C#]
public string QueueDirectory {get; set;}

Property Value

A string value. The default value is null.

Remarks

This property requires the SendToQueue property to be set to True.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Send Messages to the Queue Directory
                 oSmtpDotNet.SendToQueue = true;
                 oSmtpDotNet.QueueDirectory = "C:\\MyQueue";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Send Messages to the Queue Directory
                 oSmtpDotNet.SendToQueue = true
                 oSmtpDotNet.QueueDirectory = "C:\MyQueue"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | PickupDirectory | SendToQueue | QueueDateTime | QueueFilenames | SendToPickupDirectory | RandomObject


SmtpServer.QueueFilenames Property

A StringCollection object containing the fully qualified pathname(s) of the files crated for the queue.

[Visual Basic]
Public ReadOnly Property QueueFilenames As StringCollection
[C#]
public System.Collections.Specialized.StringCollection QueueFilenames {get;}

Property Value

A string value set after it is created.

Remarks

The filename is randomly generated and cannot be set

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Send message to the Queue Directory
                 oSmtpDotNet.SendToQueue = true;
                 oSmtpDotNet.QueueDateTime = DateTime.Now;
                 oSmtpDotNet.QueueDirectory = "C:\\Temp";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Display the queue filename that was created.
                 Console.Write(oSmtpDotNet.QueueFilename);

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Send message to the Queue Directory
                 oSmtpDotNet.SendToQueue = true
                 oSmtpDotNet.QueueDateTime = DateTime.Now;
                 oSmtpDotNet.QueueDirectory = "C:\Temp"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Display the queue filename that was created.
                 Console.Write(oSmtpDotNet.QueueFilename)

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | PickupDirectory | SendToQueue | QueueDirectory | QueueDateTime | SendToPickupDirectory | RandomObject


SmtpServer.RandomObject Property

An object of class Random that is used to ensure uniqueness with Smtp.NET and emailQ.NET queueing. Specifically important if using Smtp.NET in a multithreaded environment.

[Visual Basic]
Public Property RandomObject As Random
[C#]
public System.Random RandomObject {get; set;}

Property Value

An object of type Random. The default value is null.

Remarks

If you are creating Smtp.NET objects in multiple threads, it is suggested that you create a Random object in your calling program and pass it to this property. This property only affects messages that are sent to the Queue or Pickup Directory.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Send Messages to the Queue Directory
                 oSmtpDotNet.SendToPickupDirectory = true;
                 oSmtpDotNet.QueueDirectory = "C:\\temp\\emailQ";
                 // Set the Random object to maintain uniqueness with files
                 // created for queuing.
                 oSmtpDotNet.RandomObject = new Random();

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Send Messages to the Queue Directory
                 oSmtpDotNet.SendToPickupDirectory = true
                 oSmtpDotNet.QueueDirectory = "C:\temp\emailQ"
                 // Set the Random object to maintain uniqueness with files
                 // created for queuing.
                 oSmtpDotNet.RandomObject = new Random()

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | PickupDirectory | SendToQueue | QueueDirectory | QueueDateTime | SendToPickupDirectory


SmtpServer.ReadReceiptFrom Property

Email address to send the read receipt to

[Visual Basic]
Public Property ReadReceiptFrom As String
[C#]
public string ReadReceiptFrom {get; set;}

Property Value

A string that is the email address to send a read receipt to.

Remarks

Not all mail reader programs support this property.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the email address for the read receipt
                 oSmtpDotNet.ReadReceiptFrom = "email@domain.com";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set the email address for the read receipt
                 oSmtpDotNet.ReadReceiptFrom = "email@domain.com"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ReadReceiptFromFriendly


SmtpServer.ReadReceiptFromFriendly Property

Friendly name to send the read receipt to

[Visual Basic]
Public Property ReadReceiptFromFriendly As String
[C#]
public string ReadReceiptFromFriendly {get; set;}

Property Value

A string that specifies a friendly name to display in place of the read reciept email address in a email reader.

Remarks

Not all mail reader programs support this property. Requires ReadReceiptFrom property to be set.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Set the email address for the read receipt and the friendly name
                 oSmtpDotNet.ReadReceiptFrom = "email@domain.com";
                 oSmtpDotNet.ReadReceiptFromFriendly = "John  Doe";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Set the email address for the read receipt and the friendly name
                 oSmtpDotNet.ReadReceiptFrom = "email@domain.com"
                 oSmtpDotNet.ReadReceiptFromFriendly = "John  Doe"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ReadReceiptFrom


SmtpServer.ReplyToAddress Property

Specifies the reply-to address

[Visual Basic]
Public Property ReplyToAddress As String
[C#]
public string ReplyToAddress {get; set;}

Property Value

A string containing an email address

Remarks

Not all mail servers and email clients support this feature.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Set the reply to address which is different than the from address.
                 oSmtpDotNet.ReplyToAddress = "reply@domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the reply to address which is different than the from address.
                 oSmtpDotNet.ReplyToAddress = "reply@domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ReplyToFriendly


SmtpServer.ReplyToFriendly Property

Specifies the friendly name for the reply-to address.

[Visual Basic]
Public Property ReplyToFriendly As String
[C#]
public string ReplyToFriendly {get; set;}

Property Value

A string containing an email address

Remarks

Not all mail servers and email clients support this feature.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Set the reply to address which is different than the from address.
                 oSmtpDotNet.ReplyToAddress = "reply@domain.com";
                 oSmtpDotNet.ReplyToFriendly = "Email Reply Center";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the reply to address which is different than the from address.
                 oSmtpDotNet.ReplyToAddress = "reply@domain.com"
                 oSmtpDotNet.ReplyToFriendly = "Email Reply Center"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ReplyToAddress


SmtpServer.SendDelay Property

Specifies the amount of time in milliseconds to wait before sending the next email message.

[Visual Basic]
Public Property SendDelay As Integer
[C#]
public int SendDelay {get; set;}

Property Value

An integer value between 0 and 9999999. The default value is 0.

Remarks

Only applies when sending more than one email, for example when using MailMerge.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the DBDataTable to an object that is of type DataTable
                 oSmtpDotNet.DBDataTable = myDataTable;

                 // Set other DB properties
                 oSmtpDotNet.DBRecipientType = AddressTypes.TO;
                 oSmtpDotNet.DBEmailColumn = "email";
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName";

                 // Set the delay between message sending
                 oSmtpDotNet.SendDelay = 30000; // 30 second delay

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the DBDataTable to an object that is of type DataTable
                 oSmtpDotNet.DBDataTable = myDataTable

                 oSmtpDotNet.DBRecipientType = AddressTypes.TO
                 ' Set other DB properties
                 oSmtpDotNet.DBEmailColumn = "email"
                 oSmtpDotNet.DBFriendlyColumn = "customerFirstName,customerLastName"

                 ' Set the delay between message sending
                 oSmtpDotNet.SendDelay = 30000 ' 30 second delay

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.SendToPickupDirectory Property

Specifies whether to create a "eml" file that is recognized by IIS/Exchange Smtp Server.

[Visual Basic]
Public Property SendToPickupDirectory As Boolean
[C#]
public bool SendToPickupDirectory {get; set;}

Property Value

True or False. The default value is False.

Remarks

This property requires the QueueDirectory property to be set. Setting this property to true, will create an "eml" file that is placed in the directory specified with the PickupDirectory property.

If the property SendToQueue is also set to true, messages will be first sent to the queue directory, as specified by the QueueDirectory property, then routed to the IIS/Exchange Pickup Directory as specified by the PickupDirectory property. This is useful for scheduling delivery of message through IIS/Exchange.

** Caveat to queuing logic: If the following conditions are met, then the message will be dropped in the PickupDirectory and NOT go through the queue: 1. SendToQueue is true 2. SendToPickupDirectory is true 3. QueueDateTime is not set or the date/time is in the past 4. PickupDirectory is set either explicitly, by setting the property or the IUSR_MACHINENAME user has access to the registry and an entry for PickupDirectory exists.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Send messages to the Pickup Directory
                 oSmtpDotNet.SendToPickupDirectory = true;
                 oSmtpDotNet.PickupDirectory = "C:\\Inetpub\\mailroot\\Pickup";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Send Messages to the Pickup Directory
                 oSmtpDotNet.SendToPickupDirectory = true
                 oSmtpDotNet.PickupDirectory = "C:\Inetpub\mailroot\Pickup"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | PickupDirectory | SendToQueue | QueueDirectory | QueueDateTime | RandomObject


SmtpServer.SendToQueue Property

Specifies whether to send messages to emailQ.

[Visual Basic]
Public Property SendToQueue As Boolean
[C#]
public bool SendToQueue {get; set;}

Property Value

True or False. The default is False.

Remarks

If this property is set to true, all messages will be sent to the queue directory that is specified with the QueueDirectory property or as specified in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\EMAILQ\QueueDirectory. This property is provided as an alternative to giving the IUSR_MACHINENAME user access to the registry. ** Caveat to queuing logic: If the following conditions are met, then the message will be dropped in the PickupDirectory and NOT go through the queue: 1. SendToQueue is true 2. SendToPickupDirectory is true 3. QueueDateTime is not set or the date/time is in the past 4. PickupDirectory is set either explicitly, by setting the property or the IUSR_MACHINENAME user has access to the registry and an entry for PickupDirectory exists.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Send message to the Queue Directory
                 oSmtpDotNet.SendToQueue = true;
                 oSmtpDotNet.QueueDirectory = "C:\\Temp";

                 // Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Body = "This is the message"
                 oSmtpDotNet.Subject = "Routine email"

                 ' Send message to the Queue Directory
                 oSmtpDotNet.SendToQueue = true
                 oSmtpDotNet.QueueDirectory = "C:\Temp"

                 ' Force the message body to be html
                 oSmtpDotNet.BodyFormat = BodyFormatTypes.HTML

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | PickupDirectory | QueueDirectory | QueueDateTime | QueueFilenames | SendToPickupDirectory | RandomObject


SmtpServer.ServerAddress Property

SMTP mail server addresses, e.g. mail.domain.com or 192.0.0.1. Separate multiple servers with a comma, e.g. mail.domain.com,192.0.0.1,localhost, etc.

[Visual Basic]
Public Property ServerAddress As String
[C#]
public string ServerAddress {get; set;}

Property Value

A string that specifies one or more mail server addresses seperated by a comma.

Remarks

If this property is not set, "localhost" is assumed. When multiple servers are specified, each additional server is used in the event that the object is unable to connect to the first mail server.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "localhost,192.0.0.1,mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "localhost,192.0.0.1,mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.Subject Property

The message subject.

[Visual Basic]
Public Property Subject As String
[C#]
public string Subject {get; set;}

Property Value

A string that is the message subject.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.TempDirectory Property

Temporary directory for storing images and files downloaded using the html formatted messaging features AND the directory used when the AutoNameLogFile property is set to true.

[Visual Basic]
Public Property TempDirectory As String
[C#]
new public string TempDirectory {get; set;}

Property Value

A string that specifies the temporary directory to create files for downloading web pages using the BodyUrl and AltBodyUrl properties.

Remarks

If not specified then the system temporary directory is used. In all cases, you should ensure that the user invoking this object has permission to create, open, modify and delete files in the temporary directory.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the temporary directory
                 oSmtpDotNet.TempDirectory = "C:\\temp";

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the temporary directory
                 oSmtpDotNet.TempDirectory = "C:\temp"

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | BodyUrl | AutoNameLogFile


SmtpServer.TestMode Property

Enables or disables test mode. If test mode is turned on, calling the Send method, the mail message is prepared, the mail server is connected to, but the message is never actually sent.

[Visual Basic]
Public Property TestMode As Boolean
[C#]
public bool TestMode {get; set;}

Property Value

If true, then messages are only prepared and never sent. If false, messages are prepared and sent as normal.

Remarks

The default value is false. TestMode is useful to ensure that all of the properties and methods you are using are correct before sending the message to the mail server.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Execute in test mode
                 oSmtpDotNet.TestMode = true;

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Execute in test mode
                 oSmtpDotNet.TestMode = True

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.TimeoutConnect Property

Specifies the Connection timeout in milliseconds.

[Visual Basic]
Public Property TimeoutConnect As Integer
[C#]
public int TimeoutConnect {get; set;}

Property Value

An integer value between 1 and 999999 that represents the number of milliseconds that connection to the mail server should pass before timing out.

Remarks

The default value is 5000 (5 seconds). This timeout is used to set the amount of time before an operation times out when connecting to the mail server and passing commands to that server such as message addressing. It is not the timeout for sending the actual message data including attachments which require more time before timing out.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Set the connection timeout to 1 second (1000ms).
                 oSmtpDotNet.TimeoutConnect = 1000;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the connection timeout to 1 second (1000ms).
                 oSmtpDotNet.TimeoutConnect = 1000

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | TimeoutGeneral


SmtpServer.TimeoutGeneral Property

Specifies the General timeout in milliseconds.

[Visual Basic]
Public Property TimeoutGeneral As Integer
[C#]
public int TimeoutGeneral {get; set;}

Property Value

An integer value between 1 and 9999999 that represents the number of milliseconds that a general command sent to the mail server should pass before timing out.

Remarks

The default value is 60000 (1 minutes). This timeout is used to set the amount of time before an operation times out when sending the actual message data including attachments which require more time before timing out. If the operation times out before the entire message is sent, try increasing this value.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com";

                 // Set the general timeout to 1 second (1000ms).
                 oSmtpDotNet.TimeoutGeneral = 1000;

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Set the general timeout to 1 second (1000ms).
                 oSmtpDotNet.TimeoutGeneral = 1000

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | TimeoutConnect


SmtpServer.ToAddress Property

The TO email address.

[Visual Basic]
Public Property ToAddress As String
[C#]
public string ToAddress {get; set;}

Property Value

A string that is an email address for the TO field.

Remarks

This property is intended for one to email address. If addressing multiple to email addresses, use the AddRecipient method.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AddRecipient | ToFriendly


SmtpServer.ToFriendly Property

The message TO "friendly" name. Instead of the TO email address being displayed in the recipient's email reader program, the "friendly" name is displayed.

[Visual Basic]
Public Property ToFriendly As String
[C#]
public string ToFriendly {get; set;}

Property Value

A string that specifies a friendly name to display in place of the email address in a email reader.

Remarks

Not all SMTP servers support this feature. Not all mail reader programs support displaying of the friendly name.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer();

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the to friendly name
                 oSmtpDotNet.ToFriendly = "John  Doe";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer()
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the to friendly name
                 oSmtpDotNet.ToFriendly = "John  Doe"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ToAddress


SmtpServer.ZipAttachments Property

Specifies whether to zip compress attachments automatically.

[Visual Basic]
Public Property ZipAttachments As Boolean
[C#]
public bool ZipAttachments {get; set;}

Property Value

true or false. The default is false.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO");
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Add an attachment
                 oSmtpDotNet.AddAttachment("C:\\temp\\files.zip");
                 oSmtpDotNet.ZipAttachments = true;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO")
                 oSmtpDotNet.FromAddress = "from@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Add an attachment
                 oSmtpDotNet.AddAttachment("C:\temp\files.zip")
                 oSmtpDotNet.ZipAttachments = true

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ZipCompressionLevel | ZipFilename


SmtpServer.ZipCompressionLevel Property

Sets the Zip compression level

[Visual Basic]
Public Property ZipCompressionLevel As Integer
[C#]
public int ZipCompressionLevel {get; set;}

Property Value

A number between 0 and 9 where 0 is no compression and 9 is maximum compression. The default is 9.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO");
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Add an attachment
                 oSmtpDotNet.AddAttachment("C:\\temp\\files.zip");
                 oSmtpDotNet.ZipAttachments = true;
                 oSmtpDotNet.ZipCompressionLevel = 5;

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO")
                 oSmtpDotNet.FromAddress = "from@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Add an attachment
                 oSmtpDotNet.AddAttachment("C:\temp\files.zip")
                 oSmtpDotNet.ZipAttachments = True
                 oSmtpDotNet.ZipCompressionLevel = 5

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ZipAttachments | ZipFilename


SmtpServer.ZipFilename Property

Specifies the name of the zip file, which all of the attachments are compressed into. This is the name of the file seen in the email client when the email is opened.

[Visual Basic]
Public Property ZipFilename As String
[C#]
public string ZipFilename {get; set;}

Property Value

A filename without a path. The default is attachment.zip

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO");
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Add an attachment
                 oSmtpDotNet.AddAttachment("C:\\temp\\report.xls");
                 oSmtpDotNet.ZipAttachments = true;
                 oSmtpDotNet.ZipFilename = "files.zip";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO")
                 oSmtpDotNet.FromAddress = "from@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Add an attachment
                 oSmtpDotNet.AddAttachment("C:\temp\report.xls")
                 oSmtpDotNet.ZipAttachments = true
                 oSmtpDotNet.ZipFilename = "files.zip"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ZipAttachments | ZipCompressionLevel


SmtpServer Methods

The methods of the SmtpServer class are listed below. For a complete list of SmtpServer class members, see the SmtpServer Members topic.

Public Static (Shared) Methods

GetWebPageHtml | Downloads the specified URL and puts HTML into a string buffer.
SendQuick | Sends simple message that does not allow any other parameters or properties to be set.
Version | Specifies the current version of the SmtpDotNet assembly.

Public Instance Methods

AddAttachment | Overloaded. Adds an attachment to the current message
AddRecipient | Overloaded. Add a recipient to the mail message.
Equals (inherited from Object) | Determines whether the specified Object is equal to the current Object.
GetHashCode (inherited from Object) | Serves as a hash function for a particular type, suitable for use in hashing algorithms and data structures like a hash table.
GetType (inherited from Object) | Gets the Type of the current instance.
LogFileToString | Returns the current log file as a string.
MailMerge | Combines data from the DBDataTable with various properties in the message.
SaveInMemoryLog | Saves an in-memory log to a physical file as specified by LogFilename
Send | Overloaded. Send the message.
ToString (inherited from Object) | Returns a String that represents the current Object.

See Also

SmtpServer Class | SmtpDotNet Namespace


AddAttachment Method

Smtp.NET 3 Documentation

SmtpServer.AddAttachment Method

Adds an attachment to the current message

Overload List

Adds an attachment to the current message

public bool AddAttachment(string);

Adds an attachment to the current message

public bool AddAttachment(string,string);

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.AddAttachment Method (String)

Adds an attachment to the current message

[Visual Basic]
Overloads Public Function AddAttachment( _
   ByVal pathname As String _
) As Boolean
[C#]
public bool AddAttachment(
string pathname
);

Parameters

pathname
Fully qualified pathname to the file to be attached.

Return Value

false if file does not exist, or true if file exists.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO");
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Add an attachment
                 oSmtpDotNet.AddAttachment("C:\\temp\\files.zip");

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO")
                 oSmtpDotNet.FromAddress = "from@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Add an attachment
                 oSmtpDotNet.AddAttachment("C:\temp\files.zip")

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer.AddAttachment Overload List


SmtpServer.AddAttachment Method (String, String)

Adds an attachment to the current message

[Visual Basic]
Overloads Public Function AddAttachment( _
   ByVal pathname As String, _
   ByVal contentType As String _
) As Boolean
[C#]
public bool AddAttachment(
string pathname,
string contentType
);

Parameters

pathname
Fully qualified pathname to the file to be attached.
contentType
Overridable content-type.

Return Value

false if file does not exist, or true if file exists.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO");
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 // Add an attachment
                 oSmtpDotNet.AddAttachment("C:\temp\files.zip", "application/zip");

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO")
                 oSmtpDotNet.FromAddress = "from@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Add an attachment
                 oSmtpDotNet.AddAttachment("C:\temp\files.zip", "application/zip")

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer.AddAttachment Overload List


AddRecipient Method

Smtp.NET 3 Documentation

SmtpServer.AddRecipient Method

Add a recipient to the mail message.

Overload List

Add a recipient to the mail message.

public bool AddRecipient(string,string,AddressTypes);

Overloaded adding of a recipient to the mail message, however you can pass in "TO", "CC", or "BCC"

public bool AddRecipient(string,string,string);

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | AddressTypes


SmtpServer.AddRecipient Method (String, String, AddressTypes)

Add a recipient to the mail message.

[Visual Basic]
Overloads Public Function AddRecipient( _
   ByVal emailAddress As String, _
   ByVal friendlyName As String, _
   ByVal type As AddressTypes _
) As Boolean
[C#]
public bool AddRecipient(
string emailAddress,
string friendlyName,
AddressTypes type
);

Parameters

emailAddress
An email address
friendlyName
A friendly name
type
An adress type of AddressTypes. This parameter must be cast to int

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", AddressTypes.TO);
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", AddressTypes.TO)
                 oSmtpDotNet.FromAddress = "from@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer.AddRecipient Overload List | AddressTypes


SmtpServer.AddRecipient Method (String, String, String)

Overloaded adding of a recipient to the mail message, however you can pass in "TO", "CC", or "BCC"

[Visual Basic]
Overloads Public Function AddRecipient( _
   ByVal emailAddress As String, _
   ByVal friendlyName As String, _
   ByVal type As String _
) As Boolean
[C#]
public bool AddRecipient(
string emailAddress,
string friendlyName,
string type
);

Parameters

emailAddress
An email address
friendlyName
A friendly name
type
"TO", "CC", or "BCC"

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO");
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing.  Instead of using the ToAddress property...
                 oSmtpDotNet.AddRecipient("to@domain.com", "Bob Barker", "TO")
                 oSmtpDotNet.FromAddress = "from@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer.AddRecipient Overload List | AddressTypes


SmtpServer.GetWebPageHtml Method

Downloads the specified URL and puts HTML into a string buffer.

[Visual Basic]
Public Shared Function GetWebPageHtml( _
   ByVal Url As String _
) As String
[C#]
public static string GetWebPageHtml(
string Url
);

Parameters

Url
The URL to download

Return Value

String that contains HTML

Remarks

This method is provided as a helpful utility for downloading a web page into a local string.

Example

[C#]
            public void Send()
            {
                 string sHTML = SmtpServer.GetWebPageHtml("http://www.yahoo.com");
            }

[VB]
            Public Function Send() As Integer
                 Dim sHTML As String

                 sHTML = SmtpServer.GetWebPageHtml("http://www.yahoo.com")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.LogFileToString Method

Returns the current log file as a string.

[Visual Basic]
Public Function LogFileToString( _
   ByVal htmlEncode As Boolean _
) As String
[C#]
public string LogFileToString(
bool htmlEncode
);

Parameters

htmlEncode
Encode for displaying in HTML context

Return Value

A string containing the log file.

Remarks

Requires InMemoryLog to be set to True. This is useful for displaying in your application for debugging purposes.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 oSmtpDotNet.InMemoryLog = true;

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 oSmtpDotNet.InMemoryLog = true

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpServer.MailMerge Method

Combines data from the DBDataTable with various properties in the message.

[Visual Basic]
Public Function MailMerge( _
   ByVal dataTable As DataTable, _
   ByVal emailColumn As String, _
   ByVal recipientType As AddressTypes, _
   ByVal replacementIds As Hashtable _
) As ReturnCodes
[C#]
public ReturnCodes MailMerge(
DataTable dataTable,
string emailColumn,
AddressTypes recipientType,
Hashtable replacementIds
);

Parameters

dataTable
A datatable that contains the data to use in the mail merge.
emailColumn
The name of the column in the data table that holds email addresses.
recipientType
The recipient type for the addresses in the DBDataTable of enumerated type AddressTypes
replacementIds
A hashtable of replacement tags to use with mail merge functionality. Each key of the array should a string that Smtp.NET will search for and replace in your message body, subject, etc.. For example, if the key is "$email$" - Smtp.NET will search for the string $email$ in the message body, subject, and addressing. The value of the hashtable represents the name(s) of columns to pull data from for replacement. You can pull data from multiple columns by seperating values with a comma. Example: key="$name$", value="first_name,last_name".

NOTE: The search that is performed is case-sensitive. If you specify $email$ as a replacement id, your message should contain $email$, not $Email$.

Return Value

An integer of enumerated type ReturnCodes.

Remarks

After this method is called, all recipients in the "to", "cc", "bcc" fields are cleared.

Events

Event Type | Reason
 | After each email message is sent, this event will be raised with the current DataRow in the specified DataTable and the percentage complete of the entire mail merge. See: ProgressEventHandler for a complete example.

Example

For example: In the message, "Dear $A$: Thank you for ordering $B$ from our $C$ store...", $A$, $B$ and $C$ are merge points into which data is inserted from the list.

Letter | Database
Dear $A$: Thank you for ordering $B$ at our $C$ store. Sincerely, The store owners | $A$ | $B$ | $C$
 | Mr. Smith | 1 Widget | New York
 | Ms. Gomer | 2 Dingits | Chicago
 | Mr. Jones | 1 Frabbits | Los Angeles
 | Mr. Silver | 3 Widgets | Tucson
 | Ms. Change | 2 Gobbits | Philadelphia
 | Mr. Russion | 5 Wibbles | Washington D.C

Example Output (without formatting):

Dear Mr. Smith: Thank you for ordering 1 Widget at our New York store. Sincerely, The store owners

Dear Ms. Gomer: Thank you for ordering 2 Dingits at our Chicago store. Sincerely, The store owners

Dear Mr. Jones: Thank you for ordering 1 Frabbits at our Los Angeles store. Sincerely, The store owners

Dear Mr. Silver: Thank you for ordering 3 Widgets at our Tucson store. Sincerely, The store owners

Dear Ms. Change: Thank you for ordering 2 Gobbits at our Philadelphia store. Sincerely, The store owners

Dear Mr. Russion: Thank you for ordering 3 Wibbles at our Washington D.C. store. Sincerely, The store owners

[C#]
public void Send()
{
     SmtpServer oSmtpDotNet = new SmtpServer();

     // Set the remote server name.  If left blank, "localhost" is used.
     oSmtpDotNet.ServerAddress = "mail.domain.com"

     // Message Addressing
     oSmtpDotNet.FromAddress = "from@domain.com";

   // Set the message subject and body
   oSmtpDotNet.Body = "Dear $A$:  Thank you for ordering $B$ at our $C$ store.  Sincerely, The store owners";
   oSmtpDotNet.Subject = "Your order of $B$";

   // Set up the hashtable for the mail merge replacements.
   Hashtable oHashtable = new Hashtable();
   oHashtable.Add("$A$", "customerSalutation,customerLastName");
   oHashtable.Add("$B$", "itemCount,itemName");
   oHashtable.Add("$C$", "itemStoreSoldName");
   ReturnCodes nRC = oSmtpDotNet.MailMerge(dataTable, "customerEmail", SmtpDotNet.AddressTypes.TO, oHashtable);

     if ( nRC != ReturnCodes.SUCCESS )
     {
          Console.WriteLine("Error #"+nRC+" occurred.");
          Console.WriteLine(oSmtpDotNet.LastError);
          Console.Write(oSmtpDotNet.LogFileToString(false));
          return;
     }

     // Success!
     Console.WriteLine("Success!");
}

[VB]
Public Function Send() As Integer
     Dim oSmtpDotNet As New SmtpServer()
     Dim nRC As ReturnCodes

     ' Set the remote server name.  If left blank, "localhost" is used.
     oSmtpDotNet.ServerAddress = "mail.domain.com"

     ' Message Addressing
     oSmtpDotNet.FromAddress = "from@domain.com"

   ' Set the message subject and body
   oSmtpDotNet.Body = "Dear $A$:  Thank you for ordering $B$ at our $C$ store.  Sincerely, The store owners"
   oSmtpDotNet.Subject = "Your order of $B$"

   ' Set up the hashtable for the mail merge replacements.
   Hashtable oHashtable = new Hashtable()
   oHashtable.Add("$A$", "customerSalutation,customerLastName")
   oHashtable.Add("$B$", "itemCount,itemName")
   oHashtable.Add("$C$", "itemStoreSoldName")
   ReturnCodes nRC = oSmtpDotNet.MailMerge(dataTable, "customerEmail", SmtpDotNet.AddressTypes.TO, oHashtable)

     If (nRC <> ReturnCodes.SUCCESS) Then
         ' A problem occurred.
         ' Write out the last error encountered
         Console.WriteLine(oSmtpDotNet.LastError)
         ' Write out the log file contents
         Console.WriteLine(oSmtpDotNet.LogFileToString(False))
         Exit Function
     End If

     ' Success!
     Console.WriteLine("Message Sent!")
End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ReturnCodes


SmtpServer.SaveInMemoryLog Method

Saves an in-memory log to a physical file as specified by LogFilename

[Visual Basic]
Overrides Public Function SaveInMemoryLog() As Boolean
[C#]
public override bool SaveInMemoryLog();

Return Value

true if successful, false if faled

Remarks

Requires InMemoryLog to be set to True.

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 oSmtpDotNet.InMemoryLog = true;

                 // Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 // Message Addressing
                 oSmtpDotNet.ToAddress = "to@domain.com";
                 oSmtpDotNet.FromAddress = "from@domain.com";

                 // Set the message subject and body
                 oSmtpDotNet.Body = "This is the message";
                 oSmtpDotNet.Subject = "Routine email";

                 ReturnCodes nRC = oSmtpDotNet.Send();
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.WriteLine("Error #"+nRC+" occurred.");
                      Console.WriteLine(oSmtpDotNet.LastError);
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                      return;
                 }

                 // Success!
                 Console.WriteLine("Success!");

                 // Now save the in-memory log to the file "d:\\temp\\log.txt"
                 oSmtpDotNet.SaveInMemoryLog();
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")
                 Dim nRC As ReturnCodes

                 oSmtpDotNet.InMemoryLog = true

                 ' Set the remote server name.  If left blank, "localhost" is used.
                 oSmtpDotNet.ServerAddress = "mail.domain.com"

                 ' Message Addressing
                 oSmtpDotNet.FromAddress = "from@domain.com"
                 oSmtpDotNet.ToAddress = "to@domain.com"

                 ' Set the message subject and body
                 oSmtpDotNet.Subject = "Routine email"
                 oSmtpDotNet.Body = "This is a briefing of the financials"

                 ' Send the message.  Get the return code and store it in the variable
                 ' nRC.  Then check nRC for success or failure
                 nRC = oSmtpDotNet.Send()
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     ' A problem occurred.
                     ' Write out the last error encountered
                     Console.WriteLine(oSmtpDotNet.LastError)
                     ' Write out the log file contents
                     Console.WriteLine(oSmtpDotNet.LogFileToString(False))
                     Exit Function
                 End If

                 ' Success!
                 Console.WriteLine("Message Sent!")

                 ' Now save the in-memory log to the file "d:\temp\log.txt"
                 oSmtpDotNet.SaveInMemoryLog()
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | InMemoryLog


Send Method

Smtp.NET 3 Documentation

SmtpServer.Send Method

Send the message.

Overload List

Send the message.

public ReturnCodes Send(string,string,string,string);

Send the message.

public ReturnCodes Send();

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ReturnCodes | SendQuick


SmtpServer.Send Method ()

Send the message.

[Visual Basic]
Overloads Public Function Send() As ReturnCodes
[C#]
public ReturnCodes Send();

Return Value

An enumerated value of ReturnCodes

Remarks

After this method is called, all recipients in the "to", "cc", "bcc" fields are cleared.

Events

Event Type | Reason
 | If DBDataTable is specified, this event will be raised with the percentage complete See: ProgressEventHandler for a complete example.

Example

[C#]
public void Send()
{
     SmtpServer oSmtpDotNet = new SmtpServer();

     // Set the remote server name.  If left blank, "localhost" is used.
     oSmtpDotNet.ServerAddress = "mail.domain.com"

     // Message Addressing
     oSmtpDotNet.ToAddress = "to@domain.com";
     oSmtpDotNet.FromAddress = "from@domain.com";

     // Set the message subject and body
     oSmtpDotNet.Body = "This is the message";
     oSmtpDotNet.Subject = "Routine email";

     ReturnCodes nRC = oSmtpDotNet.Send();
     if ( nRC != ReturnCodes.SUCCESS )
     {
          Console.WriteLine("Error #"+nRC+" occurred.");
          Console.WriteLine(oSmtpDotNet.LastError);
              Console.Write(oSmtpDotNet.LogFileToString(false));
          return;
     }

     // Success!
     Console.WriteLine("Success!");
}

[VB]
Public Function Send() As Integer
     Dim oSmtpDotNet As New SmtpServer()
     Dim nRC As ReturnCodes

     ' Set the remote server name.  If left blank, "localhost" is used.
     oSmtpDotNet.ServerAddress = "mail.domain.com"

     ' Message Addressing
     oSmtpDotNet.FromAddress = "from@domain.com"
     oSmtpDotNet.ToAddress = "to@domain.com"

     ' Set the message subject and body
     oSmtpDotNet.Subject = "Routine email"
     oSmtpDotNet.Body = "This is a briefing of the financials"

     ' Send the message.  Get the return code and store it in the variable
     ' nRC.  Then check nRC for success or failure
     nRC = oSmtpDotNet.Send()
     If (nRC <> ReturnCodes.SUCCESS) Then
         ' A problem occurred.
         ' Write out the last error encountered
         Console.WriteLine(oSmtpDotNet.LastError)
         ' Write out the log file contents
         Console.WriteLine(oSmtpDotNet.LogFileToString(False))
         Exit Function
     End If

     ' Success!
     Console.WriteLine("Message Sent!")
End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer.Send Overload List | ReturnCodes | SendQuick


SmtpServer.Send Method (String, String, String, String)

Send the message.

[Visual Basic]
Overloads Public Function Send( _
   ByVal sToAddress As String, _
   ByVal sFromAddress As String, _
   ByVal sSubject As String, _
   ByVal sBody As String _
) As ReturnCodes
[C#]
public ReturnCodes Send(
string sToAddress,
string sFromAddress,
string sSubject,
string sBody
);

Parameters

sToAddress
The "to" email address
sFromAddress
The "from" email address
sSubject
The "subject" of the email
sBody
The "body" of the email

Return Value

An enumerated value of ReturnCodes

Remarks

After this method is called, all recipients in the "to", "cc", "bcc" fields are cleared.

Events

Event Type | Reason
 | If DBDataTable is specified, this event will be raised with the percentage complete See: ProgressEventHandler for a complete example.

Example

[C#]
public void Send()
{
     SmtpServer oSmtpDotNet = new SmtpServer();

     // Set the remote server name.  If left blank, "localhost" is used.
     oSmtpDotNet.ServerAddress = "mail.domain.com"

     // Message Addressing
     oSmtpDotNet.ToAddress = "to@domain.com";
     oSmtpDotNet.FromAddress = "from@domain.com";

     // Set the message subject and body
     oSmtpDotNet.Body = "This is the message";
     oSmtpDotNet.Subject = "Routine email";

     ReturnCodes nRC = oSmtpDotNet.Send();
     if ( nRC != ReturnCodes.SUCCESS )
     {
          Console.WriteLine("Error #"+nRC+" occurred.");
          Console.WriteLine(oSmtpDotNet.LastError);
              Console.Write(oSmtpDotNet.LogFileToString(false));
          return;
     }

     // Success!
     Console.WriteLine("Success!");
}

[VB]
Public Function Send() As Integer
     Dim oSmtpDotNet As New SmtpServer()
     Dim nRC As ReturnCodes

     ' Set the remote server name.  If left blank, "localhost" is used.
     oSmtpDotNet.ServerAddress = "mail.domain.com"

     ' Message Addressing
     oSmtpDotNet.FromAddress = "from@domain.com"
     oSmtpDotNet.ToAddress = "to@domain.com"

     ' Set the message subject and body
     oSmtpDotNet.Subject = "Routine email"
     oSmtpDotNet.Body = "This is a briefing of the financials"

     ' Send the message.  Get the return code and store it in the variable
     ' nRC.  Then check nRC for success or failure
     nRC = oSmtpDotNet.Send()
     If (nRC <> ReturnCodes.SUCCESS) Then
         ' A problem occurred.
         ' Write out the last error encountered
         Console.WriteLine(oSmtpDotNet.LastError)
         ' Write out the log file contents
         Console.WriteLine(oSmtpDotNet.LogFileToString(False))
         Exit Function
     End If

     ' Success!
     Console.WriteLine("Message Sent!")
End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | SmtpServer.Send Overload List | ReturnCodes | SendQuick


SmtpServer.SendQuick Method

Sends simple message that does not allow any other parameters or properties to be set.

[Visual Basic]
Public Shared Function SendQuick( _
   ByVal sToAddress As String, _
   ByVal sFromAddress As String, _
   ByVal sSubject As String, _
   ByVal sBody As String _
) As ReturnCodes
[C#]
public static ReturnCodes SendQuick(
string sToAddress,
string sFromAddress,
string sSubject,
string sBody
);

Parameters

sToAddress
The "to" email address
sFromAddress
The "from" email address
sSubject
The "subject" of the email
sBody
The "body" of the email

Return Value

An enumerated value of ReturnCodes

Remarks

  • "After this method is called, all recipients in the "to", "cc", "bcc" fields are cleared.
  • Also see the overloaded non-static Send method that requires the creation of the SmtpServer object, but allows optional properties to be set.

Example

[C#]
            public void Send()
            {
                 ReturnCodes nRC = SmtpServer.SendQuick("to@email.com", "from@email.com", "Subject", "This is a test message");
                 if ( nRC != ReturnCodes.SUCCESS )
                 {
                      Console.Write("Error #"+nRC+" occurred.");
                 }
                 else
                 {
                      Console.Write(oSmtpDotNet.LogFileToString(false));
                 }
            }

[VB]
            Public Function Send() As Integer
                 Dim nRC As ReturnCodes
                 nRC = SmtpServer.SendQuick("to@email.com", "from@email.com", "Subject", "This is a test message");
                 If (nRC <> ReturnCodes.SUCCESS) Then
                     Console.Write("Error #"+nRC+" occurred.");
                 Else
                     ' Success!
                     Console.WriteLine("Message Sent!")
                 End If
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace | ReturnCodes | Send


SmtpServer.Version Method

Specifies the current version of the SmtpDotNet assembly.

[Visual Basic]
Public Shared Function Version() As String
[C#]
public static string Version();

Remarks

none

Example

[C#]
            public void Send()
            {
                 SmtpServer oSmtpDotNet = new SmtpServer("c:\\temp\\log.txt");

                 // Get the Version
                 Console.WriteLine(oSmtpDotNet.Version());
            }

[VB]
            Public Function Send() As Integer
                 Dim oSmtpDotNet As New SmtpServer("c:\temp\log.txt")

                 ' Get the Version
                 Console.WriteLine(oSmtpDotNet.Version())
            End Function

See Also

SmtpServer Class | SmtpServer Members | SmtpDotNet Namespace


SmtpDotNetHierarchy

Smtp.NET 3 Documentation

SmtpDotNet Hierarchy

System.Object
-CoreServer
-SmtpServer